package com.party.admin.web.controller.mall;

import com.party.admin.biz.mall.MallShowCategoryBizService;
import com.party.common.paging.Page;
import com.party.core.model.mall.MallShowCategory;
import com.party.core.model.mall.MallShowCategoryQuery;
import com.party.core.service.mall.IMallShowCategoryService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * 主题分类类型管理
 * @author cyl
 * @date 2017-8-25
 * @time 11:51
 */
@Controller
@RequestMapping("/mall/showtemplatecategory")
public class MallShowTemplateCategoryController {
	
	protected Logger logger = LoggerFactory.getLogger(MallShowTemplateCategoryController.class);

	@Autowired
	private IMallShowCategoryService mallShowCategoryService;
	
	@Autowired
	private MallShowCategoryBizService mallShowCategoryBizService;

	/**
	 * 类型列表
	 * @param mallShowCategoryQuery
	 * @param page
	 * @return
	 */
	@RequestMapping("list")
	public ModelAndView categoryList(MallShowCategoryQuery mallShowCategoryQuery,Page page) {
		ModelAndView mv = new ModelAndView("mall/showCategoryList");
		mv.addObject("templateId", mallShowCategoryQuery.getTemplateId());
		mv.addObject("page", page);
		List<MallShowCategory> list = mallShowCategoryBizService.list(mallShowCategoryQuery, page);
		mv.addObject("categoryList", list);
		return mv;
	}
	
	@RequestMapping("categoryform")
	public ModelAndView categoryForm(String id,String templateId) {
		ModelAndView mv =new ModelAndView("mall/showCategoryForm");
		mv.addObject("templateId", templateId);
		if(StringUtils.isNotEmpty(id)) {
			MallShowCategory category = mallShowCategoryService.get(id);
			mv.addObject("category", category);
		}
		return mv;
	}
}
